<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Custom Dialog</title>
  <script src="drag.js"></script>
  <link href='https://fonts.googleapis.com/css?family=Varela Round' rel='stylesheet'>
  <style>
    body {
      background-color: #0e0e0d;
      color: #fff;
      text-align: center;
      padding-top: 50px;
      font-family: 'Varela Round';
      border-radius: 10px; 
    }


    .cross-icon {
      position: absolute;
      top: 10px;
      right: 10px;
      cursor: pointer;
      font-size: 20px;
    }
    #logo {
      display: block;
      margin: 0 auto;
      max-width: 250px;
    }

    .button-container {
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    button {
      width: 200px; 
      margin: 10px;
      padding: 10px 20px;
      font-size: 16px;
      color: #ffffff;
      border: 2px solid #ffffff;
      border-radius: 5px;
      cursor: pointer;
      transform: scale(1);
      transition: color 0.3s ease-in-out, background-color 0.3s ease-in-out, transform 0.2s ease-in-out;
      font-family: 'Varela Round';
      font-weight: 520;
      background-color: transparent;
    }

   
    button:hover {
      background-color: #2c3e50;
      color: #fff;
      transform: scale(1.05); 
    }

  
    body::-webkit-scrollbar {
      width: 0.5em;
    }

    body::-webkit-scrollbar-track {
      background-color: transparent;
    }

    body::-webkit-scrollbar-thumb {
      background-color: #2c3e50;
    }

  </style>
</head>
<body>

  <span id="closeButton" class="cross-icon">✖</span>

  <img id="logo1" src="assets/icons/png/aigate1.svg" alt="Logo 1" style="position: absolute; top: 10px; left: 10px; max-width: 30px;">
  <img id="logo" src="assets/icons/png/aigaten.svg" alt="Logo">
  <h2>Choose an AI to navigate:</h2>
  <div class="button-container">
    <button id="chatgpt">ChatGPT</button>
    <button id="gemini">Google Gemini</button>
    <button id="perplexSearch">Perplexity AI Search</button>
    <button id="perplexChat">Perplexity AI Chat</button>
    <button id="claude">Claude 2</button>
  </div>

  <div id="updateContainer">
    <p id="versionDisplay">Current Version: Checking...</p>
  </div>

  <footer>
    Made with ❤️ by <a href="https://github.com/inulute" class="footerinu" style="color: antiquewhite; font-size: small;">inulute</a>
  </footer>

  <script>
    function compareVersions(v1, v2) {
        const parts1 = v1.split('.').map(Number);
        const parts2 = v2.split('.').map(Number);
        
        for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
            const part1 = parts1[i] || 0;
            const part2 = parts2[i] || 0;
            
            if (part1 > part2) return 1;
            if (part1 < part2) return -1;
        }
        
        return 0;
    }

    async function checkForUpdates() {
        try {
            const currentVersion = '2.0.0'; 
            const response = await fetch('https://raw.githubusercontent.com/inulute/ai-gate/main/package.json');
            const { version: latestVersion } = await response.json();

            const versionDisplay = document.getElementById("updateContainer");

            if (compareVersions(latestVersion, currentVersion) === 1) {

                versionDisplay.innerHTML = `
                  <p style="color: #4EB1BA;">Update Available! v${latestVersion}</p>
                  <button id="updateButton">Update Now</button>
                `;
                

                document.getElementById("updateButton").addEventListener("click", () => {
                  window.open("https://github.com/inulute/ai-gate/releases/latest", "_blank");
                });
              } else {

                versionDisplay.innerHTML = `
                <p style="color: lightyellow; font-size: x-small;">How to use? <a href="https://aigate.inulute.com/instructions" target="_blank" style="color: lightyellow;">Click Here!</a></p>
                <a href="https://donate.inulute.vercel.app" target="_blank" style="color: rgb(95, 137, 95); text-decoration: underline;">Please consider Donating</a>
                `;
            }
        } catch (error) {
            console.error("Error fetching version file:", error);
            document.getElementById("versionDisplay").innerText = "Error checking for updates.";
        }
    }

    document.addEventListener("DOMContentLoaded", function () {
        checkForUpdates();
    });
  </script>
</body>
</html>
